<?php
class page_base 
{
	private $titre;
	private $style=array('modele');
	private $corps;
	private $page;
	private $cookie;
	
	public function __construct($p) 
	{
		$this->page = $p;
		
		$cookie=0;
	}

	/******** Gestion des setters  *******************/
	public function __set($propriete, $valeur) 
	{
		switch ($propriete) 
		{
			case 'style' : 
			{
				$this->style[count($this->style)+1] = $valeur;
				break;
			}
			
			case 'corps' : 
			{
				$this->corps = $valeur;
				break;
			}
		}
	}
	
	/******** Gestion du titre  *******************/
	private function affiche_titre() 
	{
		echo $this->titre;
	}
	
	/*************Gestion des styles *********************/
	private function affiche_style() 
	{
		foreach ($this->style as $s) 
		{
			echo "<link rel='stylesheet' href='styles/".$s.".css' />\n";
		}
	}

	/************** Affichage du menu ******************************/
	private function affiche_menu()//
	{	
		if (isset($_GET['v']))
		{			
		?>
			<nav>
        		<ul class="sf-menu" id="nav">
        			<?php if($_GET['v'] == "i")
        			{?>
          				<li class="current"><a href="index.php?v=i">Accueil</a></li>
          				<?php if (isset($_SESSION['id'])) {?><li><a href="Inscription_Eleve.php?v=p">Inscription des &eacute;l&egrave;ves</a></li><?php } ?>
         				<li><a href="page.php?v=q">Autre Page</a></li>
          				<li><a href="#">Contacter nous</a></li>
          			<?php 
        			}
          			else if($_GET['v'] == "p")
          			{?>
          				<li><a href="index.php?v=i">Accueil</a></li>
          				<?php if (isset($_SESSION['id'])) {?><li class="current"><a href="Inscription_Eleve.php?v=p">Inscription des &eacute;l&egrave;ves</a></li><?php } ?>
         				<li><a href="page.php?v=q">Autre Page</a></li>
          				<li><a href="#">Contacter nous</a></li>
          			<?php
          			}
          			else if($_GET['v'] == "q")
          			{?>
          				<li><a href="index.php?v=i">Accueil</a></li>
          				<?php if (isset($_SESSION['id'])) {?><li><a href="Inscription_Eleve.php?v=p">Inscription des &eacute;l&egrave;ves</a></li><?php } ?>
         				<li class="current"><a href="page.php?v=q">Autre Page</a></li>
          				<li><a href="#">Contacter nous</a></li>
          			<?php 
          			}
          			else if($_GET['v'] == "c")
          			{?>
          				<li><a href="index.php?v=index">Accueil</a></li>
          				<?php if (isset($_SESSION['id'])) {?><li><a href="Inscription_Eleve.php?v=p">Inscription des &eacute;l&egrave;ves</a></li><?php } ?>
         				<li><a href="page.php?v=q">Autre Page</a></li>
          				<li class="current"><a href="#">Contacter nous</a></li>
          			<?php }
					else if($_GET['v'] == "j")
          			{?>
          				<li><a href="index.php?v=i">Accueil</a></li>
          				<?php if (isset($_SESSION['id'])) {?><li><a href="Inscription_Eleve.php?v=p">Inscription des &eacute;l&egrave;ves</a></li><?php } ?>
         				<li><a href="page.php?v=q">Autre Page</a></li>
          				<li><a href="#">Contacter nous</a></li>
          			<?php }?>
          			
          			
        		</ul>
      		</nav>
		<?php
		}
		else
		{
			?>
				<nav>
					<ul class="sf-menu" id="nav">
						<li class="current"><a href="index.php?v=i">Accueil</a></li>
          				<?php if (isset($_SESSION['id'])) {?><li><a href="Inscription_Eleve.php?v=p">Inscription des &eacute;l&egrave;ves</a></li><?php } ?>
         				<li><a href="page.php?v=q">Autre Page</a></li>
          				<li><a href="#">Contacter nous</a></li>
					</ul>
				</nav>
			<?php 
		}
	}
	
	/************** Affichage de l'entête ***************************/
	protected function affiche_entete() 
	{
		?>
			<header>
				<div id="logo">
        			<div id="logo_text">
     					<h1><a href="index.html">Usep 49</span></a></h1>
          				<h2>Comité Départemental USEP de Maine et Loire</h2>
        			</div>
      			</div>
      			<?php $this->affiche_menu(); ?>
            </header>
            
              <div>
          <?php
	}
	
		
	/************** Affichage du pied de la page ***************************/
	private function affiche_footer()
	{
		?>
			<footer>
				
			</footer>
		<?php
	}
	
	
	
	/***************** Gestion du contenu  *******************/
	protected function affiche_contenu()
	{
		echo $this->corps;
	}
	
	
	
	/***************** Gestion des encadrement *********************/
	private function encadre_princ()
	{	
			 
	if (!isset($_SESSION['id']) && !isset($_SESSION['mdp']))
		{
	echo '
			<form class="login-form" method="post">
  				<input type="text" name="id" placeholder="Identifiant">
        		<input type="password" name="mdp" placeholder="Mot de passe">

        		<input type="submit" value="Connexion">
  			</form>
  
  			<p>_____________________________</p>
  			<br/>
  			<p class="bandeau"><a href="inscription.php?v=j"><img src="images/bouton.png"></a></p>';

		}

		else
		{
			echo 'Bonjour '.$_SESSION['id'];
			echo '<form class="login-form" method="post"><input type="hidden" name="deco"><input type="submit" value="Deconnexion">';
			$cookie=1;
		}	
	}	
	
	
	private function encadre_lien()
	{
		?>
			<ul>
              <li><a href="http://cruseppaysdelaloire.org/">CRUSEP</a></li>
              <li><a href="http://www.ia49.ac-nantes.fr/">DSDEN de Maine et Loire</a></li>
              <li><a href="http://www.fol49.org/">FOL49</a></li>
              <li><a href="http://www.cg49.fr/">CG Maine et Loire</a></li>
              <li><a href="http://maineetloire.franceolympique.com/accueil.php">CDOS Maine et Loire</a></li>
              <li><a href="http://www.basketball49.fr/">CD Basketball 49</a></li>
              <li><a href="http://www.handball49.com/accueil.html">CD Handball 49</a></li>
              <li><a href="http://cd49rugby.sportsregions.fr/">CD Rugby 49</a></li>
              <li><a href="http://maine-et-loire.ffrandonnee.fr/">CD Randonnée 49</a></li>
              <li><a href="http://foot49.fff.fr/">CD Foot 49</a></li>
              <li><a href="http://cdhandisport49.e-monsite.com/">CD Handisport 49</a></li>
              <li><a href="http://sportadapte49.fr/">CD Sport Adapté 49</a></li>
            </ul>
		<?php
	}
	
	
	/******************** fonction permettant de se deconnecter ******************/
	public function Deconnecter()
	{
		if(isset($_POST['deco']))
		{
			session_destroy();
			$_SESSION=array();
			$cookie=0;
		}
	}
	
	/******************** Fonction permettant l'affichage de la page **************/
	public function affiche() 
	{
		if(isset($_POST['id']))
		{
			$_SESSION['id']=$_POST['id'];
		}
		
		if(isset($_POST['mdp']))
		{
			$_SESSION['mdp']=$_POST['mdp'];
		}
		$this->Deconnecter();
		?>
			<!DOCTYPE html>
			<html lang="fr">
				<head>
					<title>
						<?php $this->affiche_titre(); ?>
					</title>
					<meta charset="utf-8" />
					<?php $this->affiche_style(); ?>
					<meta http-equiv='Content-type' content='text/html; charset=utf-8' />
					<link rel='stylesheet' href='styles/validationEngine.jquery.css' type='text/css' media='screen' title='no title' charset='utf-8' />
					<link rel='stylesheet' href='styles/template.css' type='text/css' media='screen' title='no title' charset='utf-8' />
					<script src='js/jquery.js' type='text/javascript'></script>
					<script src='js/jquery.validationEngine-fr.js' type='text/javascript'></script>
					<script src='js/jquery.validationEngine.js' type='text/javascript'></script>
				</head>
				
				 <body>
					<div id="main">
						<?php $this->affiche_entete(); ?>
						<div id="site_content">
      						<div id="sidebar_container">
        						<div class="sidebar">
        							<h3>Connexion/Inscription</h3>
        				
        							<div class="sidebar_item">
        								<?php $this->encadre_princ();?>      									  
									</div>
									<div class="sidebar_base"></div>
								</div>
								<div class="sidebar">
									<h3>Lien Utiles</h3>
        							<div style="list-style-image : url(images/bullet.png);" class="sidebar_item">
        								<?php $this->encadre_lien(); ?>
									</div>
									<div class="sidebar_base"></div>
								</div>
							</div>
							<div class="content">
								<div class="content_item">
									<?php $this->affiche_contenu();  ?>
								</div>
							</div>
						</div>
						<?php $this->affiche_footer(); ?>				
					</div>
				</body>	
			</html>
		<?php
	}
}
?>